package com.semis.quartz.task;

import com.semis.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * 定时任务调度测试
 *
 * @author ruoyi
 */
@Component("ryTask")
@Slf4j
public class RyTask
{
    public Date weekendExtension(Date date,Integer hasPassDay){
        if(isWeekDay(date)){
            hasPassDay += 1;
            Date date1 = DateUtils.addDays(date, hasPassDay);
            weekendExtension(date1,hasPassDay);
        }
        return date;
    }

    public boolean isWeekDay(Date date){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        return dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY;
    }
}
